var parkingLot = []; //停车场

//停车
function park(car) {
    if (isEmpty(car)) {
        return 'error'
    }
    parkingLot.push(car);
    return 'success'
}

//取车
function pick(car) {
    var pickIndex = parkingLot.findIndex((value) => value === car);
    if (isEmpty(pickIndex)) {
        reportError('车辆不存在！');
        return 'error';
    }
    parkingLot.splice(pickIndex, 1);
    return car;
}

//判断传入参数是否为空
function isEmpty(param) {
    return param === undefined || param === null
}

//报错
function reportError(err) {
    alert(err);
}

export default {
    park,
    pick
}